package cn.itsource.ymcc.domain;

import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.io.Serializable;

/**
 * <p>
 * 会员登录账号
 * </p>
 *
 * @author whale
 * @since 2021-09-23
 */
@TableName("t_user")
@Data
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @TableField("create_time")
    private Long createTime;
    @TableField("update_time")
    private Long updateTime;
    /**
     * 三方登录名
     */
    @TableField("third_uid")
    private String thirdUid;
    /**
     * 手机号
     */
    //@NotEmpty(message = "手机不可为空")
    private String phone;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 头像
     */
    private String avatar;
    /**
     * 盐值
     */
    private String salt;
    /**
     * 昵称
     */
    @TableField("nick_name")
    private String nickName;
    /**
     * 用户状态
     */
    @TableField("bit_state")
    private Long bitState = 0l;
    /**
     * 安全级别
     */
    @TableField("sec_level")
    private Integer secLevel;
    @TableField("login_id")
    private Long loginId;


    public void addBitState(long state) {
        this.setBitState(this.getBitState() | state);
    }
    public void removeBitState(long state) {
        this.setBitState(this.getBitState() ^ state);
    }
    public boolean hasBitState(long state) {
        return (this.getBitState() & state) > 0;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }


}
